<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/12/1
  Time: 20:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>新增界面</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <script src="js/jquery-1.12.4.js" type="text/javascript"/>
    <script type="text/javascript">

        function checkName(){
            var sname = $("[name='sname']").val();
            if (sname==''||sname.length==0){
                $("[name='sname']").focus();
                alert("姓名必填");
                return false;
            }
            return true;
        }

        $(function () {
            $("myForm").submit(
                function(){
                    if (!checkName()) return false;
                    else return true;
                }
            );
        });
    </script>
</head>
<body>
    <form id="myForm" action="/doInsert" method="post">
        姓名：<input type="text" name="sname"/><br/>
        密码：<input type="password" name="spass"/><br/>
        出生日期：<input type="text" name="birthdate"/><br/>
        年级：<select name="grade.gid"><br/>
             <option value="-1">请选择</option>
                <c:forEach items="${gradeAll}" var="grade">
                    <option value="${grade.gid}">${grade.gname}</option>
                </c:forEach>
            </select>
        <input type="submit" name="submit"/>
        <input type="reset" name="reset"/>
    </form>
</body>
</html>
